package com.shallowUniverse.process.service;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.shallowUniverse.process.dto.AppointParam;
import com.shallowUniverse.process.entity.Approval;
import com.shallowUniverse.process.dto.TableField;
import com.shallowUniverse.process.exception.ApprovalNotExistException;
import com.shallowUniverse.process.exception.ProcessNodeDefinitionErrorException;
import com.shallowUniverse.process.exception.ProcessNotCompletedException;
import com.shallowUniverse.process.exception.ProcessNotFoundException;
import com.shallowUniverse.process.utils.Constant;

import java.util.List;
import java.util.Map;


/**
 * @author gs
 * @date create in 2020/12/11 16:33
 */
public interface ApprovalService {
    /**
     * description: 保存审批单 <br/>
     * author: Shuai Guo   <br/>
     * date: 2021/7/20 <br/>
     * params: [tableName, params] <br/>
     * return: int <br/>
     * version: 1.0
     */
    int save(String tableName, Map<Constant, Object> params) throws ProcessNodeDefinitionErrorException, ProcessNotFoundException;

    /**
     * description: 依据主键查询 <br/>
     * author: Shuai Guo   <br/>
     * date: 2021/7/20 <br/>
     * params: [id] <br/>
     * return: com.qianyu.process.entity.Approval <br/>
     * version: 1.0
     */
    Approval findById(Long id);

    /**
     * description: 依据流程号提供源表数据 <br/>
     * author: Shuai Guo   <br/>
     * date: 2021/7/20 <br/>
     * params: [id] <br/>
     * return: java.util.Map<java.lang.String,java.lang.Object> <br/>
     * version: 1.0
     */
    Map<String, Object> findTableData(Long id) throws ApprovalNotExistException;

    /**
     * description: 依据用户角色获取审批单 <br/>
     * author: Shuai Guo   <br/>
     * date: 2021/7/20 <br/>
     * params: [] <br/>
     * return: java.util.List<com.qianyu.process.entity.Approval> <br/>
     * version: 1.0
     * @param approval
     */
    List<Approval> findByRole(Approval approval);

    /**
     * description: 依据用户获取审批单 <br/>
     * author: Shuai Guo   <br/>
     * date: 2021/7/20 <br/>
     * params: [approval] <br/>
     * return: java.util.List<com.qianyu.process.entity.Approval> <br/>
     * version: 1.0
     *
     * @param approval
     */
    List<Approval> findByUser(Approval approval);

    /**
     * description: 修改审批单 <br/>
     * author: Shuai Guo   <br/>
     * date: 2021/7/20 <br/>
     * params: [approval] <br/>
     * return: int <br/>
     * version: 1.0
     */
    int update(Approval approval);

    /**
     * description: 查询目标表列 <br/>
     * author: Shuai Guo   <br/>
     * date: 2021/7/20 <br/>
     * params: [fid] <br/>
     * return: java.util.List<com.qianyu.process.dto.TableField> <br/>
     * version: 1.0
     */
    List<TableField> findTableFields(Long fid) throws ApprovalNotExistException;

    /**
     * description: 删除审批单 <br/>
     * author: Shuai Guo   <br/>
     * date: 2021/7/20 <br/>
     * params: [ids, isLogic] <br/>
     * return: int <br/>
     * version: 1.0
     */
    int remove(List<Long> ids, boolean isLogic) throws ProcessNotCompletedException;

    /**
     * description: 添加处理人 <br/>
     * author: Shuai Guo   <br/>
     * date: 2021/7/20 <br/>
     * params: [appointParam] <br/>
     * return: int <br/>
     * version: 1.0
     */
    int updateApprovePerson(AppointParam appointParam);

    /**
     * description: 根据角色分页查询 <br/>
     * author: Shuai Guo   <br/>
     * date: 2021/7/20 <br/>
     * params: [pageInfo] <br/>
     * return: com.baomidou.mybatisplus.core.metadata.IPage<com.qianyu.process.entity.Approval> <br/>
     * version: 1.0
     */
    IPage<Approval> findPageByRole(IPage<Approval> pageInfo, Approval approval);

    /**
     * description: 根据用户分页查询审批单 <br/>
     * author: Shuai Guo   <br/>
     * date: 2021/7/20 <br/>
     * params: [pageInfo,approval] <br/>
     * return: com.baomidou.mybatisplus.core.metadata.IPage<com.qianyu.process.entity.Approval> <br/>
     * version: 1.0
     */
    IPage<Approval> findPageByUser(IPage<Approval> pageInfo, Approval approval);

    /**
     * description: 查询所有审批单 <br/>
     * author: Shuai Guo   <br/>
     * date: 2021/7/20 <br/>
     * params: [] <br/>
     * return: java.util.List<com.qianyu.process.entity.Approval> <br/>
     * version: 1.0
     * @param approval
     */
    List<Approval> find(Approval approval);

    /**
     * description: 分页查询所有审批单 <br/>
     * author: Shuai Guo   <br/>
     * date: 2021/7/20 <br/>
     * params: [page] <br/>
     * return: com.baomidou.mybatisplus.core.metadata.IPage<com.qianyu.process.entity.Approval> <br/>
     * version: 1.0
     */
    IPage<Approval> findPage(IPage<Approval> page, Approval approval);
}
